package com.services.dao;

import java.util.List;

import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;

import com.services.domain.Departments;

import org.springframework.stereotype.Repository;

@Repository
public class DepartmentsDaoImpl implements DepartmentsDao {

    @PersistenceContext
    private EntityManager em;

    public Departments findByDepartmentId(long deptId) {
        return (Departments)em.createNamedQuery("Departments.findByDepartmentId").setParameter("pDeptId", deptId).getSingleResult();
    }
    
    public List<Departments> findAllDepartments() {
        return em.createNamedQuery("Departments.findAll").getResultList();    
    }
}
